package br.com.sgmf.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

@Entity
@Table(name = "motorista_veiculo")
public class MotoristaVeiculo implements Serializable {

	private static final long serialVersionUID = 1L;

	@EmbeddedId
	private MotoristaVeiculoPK motoristaVeiculoPK;

	@Column(nullable = false)
	@Temporal(TemporalType.TIME)
	private Date entrada;

	@Column(nullable = false)
	@Temporal(TemporalType.TIME)
	private Date saida;

	public MotoristaVeiculo(Integer motorista, Integer veiculo, Date entrada,
			Date saida) {
		this.motoristaVeiculoPK = new MotoristaVeiculoPK(motorista, veiculo);
		this.entrada = entrada;
		this.saida = saida;
	}

	public MotoristaVeiculo() {
		super();
	}

	public MotoristaVeiculoPK getMotoristaVeiculoPK() {
		return motoristaVeiculoPK;
	}

	public void setMotoristaVeiculoPK(MotoristaVeiculoPK motoristaVeiculoPK) {
		this.motoristaVeiculoPK = motoristaVeiculoPK;
	}

	public Date getEntrada() {
		return entrada;
	}

	public void setEntrada(Date entrada) {
		this.entrada = entrada;
	}

	public Date getSaida() {
		return saida;
	}

	public void setSaida(Date saida) {
		this.saida = saida;
	}

	@Override
	public int hashCode() {
		return HashCodeBuilder.reflectionHashCode(this);
	}

	@Override
	public boolean equals(Object obj) {
		return EqualsBuilder.reflectionEquals(this, obj);
	}

}
